﻿namespace PrimeNumber
{
    internal class Program
    {/// <summary>
     /// 求100000以内最大素数
     /// </summary>
     /// <param name="args"></param>
        static void Main(string[] args)
        {
            int max = 0;
            double totaltime = 0;
            Console.WriteLine("已知2为素数，则从3开始");
            DateTime dateTimestart = DateTime.Now;
            for (int i = 3; i < 100000; i += 2)
            {
                int j = 0;
                for ( j = 3; j < i; j += 2)
                {
                    if (i % j == 0)
                        break;
                }
                if (i == j)
                  max = i;
            }
            DateTime dateTimeOver = DateTime.Now;
            totaltime += (dateTimeOver - dateTimestart).TotalSeconds;
            Console.WriteLine($"最大素数为{max}，共用时{totaltime.ToString()}");
        }
    }
}